{%load static%}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MUCmarket.register</title>
    <link rel="stylesheet" href="/static/css/shell.css">
</head>

<body>
    <div class="shell">
        <div class="container a-container" id="a-container">
            <form action="" method="post" class="form" id="a-form">
                {% csrf_token %}
                <input type="hidden" name="register" >
                <h2 class="form_title title">创建账号</h2>
                <span class="form_span">请使用MUC学号注册</span>
                <input type="text" class="form_input" placeholder="Name" name='name'>
                <input type="text" class="form_input" placeholder="Student-Number" name='snum'>
                <input type="password" class="form_input" placeholder="Password" name='pwd'>
                <button class="form_button button submit">SIGN UP</button>
            </form>
        </div>

        <div class="container b-container" id="b-container">
            <form action="" method="post" class="form" id="b-form">
                {% csrf_token %}
                <input type="hidden" name="login" >  
                <h2 class="form_title title">登入账号</h2>
                <span class="form_span">请使用MUC学号登录</span>
                <input type="text" class="form_input" placeholder="Student-Number" name='snum'>
                <input type="password" class="form_input" placeholder="Password" name='pwd'>
                <a class="form_link">忘记密码？</a>
                <button class="form_button button submit">SIGN IN</button>
            </form>
        </div>

        <div class="switch" id="switch-cnt">
            <div class="switch_circle"></div>
            <div class="switch_circle switch_circle-t"></div>
            <div class="switch_container" id="switch-c1">
                <h2 class="switch_title title" style="letter-spacing: 0;">Welcome Back！</h2>
                <p class="switch_description description">已经有账号了，快来登入吧！</p>
                <button class="switch_button button switch-btn">SIGN IN</button>
            </div>

            <div class="switch_container is-hidden" id="switch-c2">
                <h2 class="switch_title title" style="letter-spacing: 0;">Hello Friend！</h2>
                <p class="switch_description description">还没有账号，快来注册吧！</p>
                <button class="switch_button button switch-btn">SIGN UP</button>
            </div>
        </div>
    </div>
</body>

</html>
<script>
    if (document.addEventListener) {
        /*event.persisted 判断浏览器是否有缓存, 有为true, 没有为false*/
        window.addEventListener('pageshow', function (event) {
            if (event.persisted || window.performance && window.performance.navigation.type == 2){
                location.reload();
            }
        },false);
 } 
    let switchCtn = document.querySelector("#switch-cnt");
    let switchC1 = document.querySelector("#switch-c1");
    let switchC2 = document.querySelector("#switch-c2");
    let switchCircle = document.querySelectorAll(".switch_circle");
    let switchBtn = document.querySelectorAll(".switch-btn");
    let aContainer = document.querySelector("#a-container");
    let bContainer = document.querySelector("#b-container");
    let allButtons = document.querySelectorAll(".submit");

    //let getButtons = (e) => e.preventDefault;
    let changeForm = (e) => {
        // 修改类名
        switchCtn.classList.add("is-gx");
        setTimeout(function () {
            switchCtn.classList.remove("is-gx");
        }, 1500)
        switchCtn.classList.toggle("is-txr");
        switchCircle[0].classList.toggle("is-txr");
        switchCircle[1].classList.toggle("is-txr");

        switchC1.classList.toggle("is-hidden");
        switchC2.classList.toggle("is-hidden");
        aContainer.classList.toggle("is-txl");
        bContainer.classList.toggle("is-txl");
        bContainer.classList.toggle("is-z");
    }
    // 点击切换
    let shell = (e) => {
        //for (var i = 0; i < allButtons.length; i++)
          //    allButtons[i].addEventListener("click", getButtons);
        for (var i = 0; i < switchBtn.length; i++)
            switchBtn[i].addEventListener("click", changeForm)
    }
    window.addEventListener("load", shell);

</script>
</body>

</html> 